reading k&r(c book) and confusing 1st chapter code [closed]

Posted by DarkEnergy on Programmers See other posts from Programmers or by DarkEnergy
Published on 2011-03-10T08:11:11Z Indexed on 2011/03/10 16:19 UTC
Read the original article Hit count: 194

Filed under:
|
#include <stdio.h>
/* copy input to output; 2nd version*/
main()
{
    int c;

    while ((c = getchar()) != EOF)
        putchar(c);
}

this is very confusing... since you never escape the while loop. I've learned that EOF is -1. i type -1 but it just reprints it. It's a never ending loop. Over time did the library get changed and differs from what the book intended it to be? when i say library i mean the putchar()/getchar() that's in the library... sorry.

© Programmers or respective owner

Related posts about programming

Related posts about c